package com.mk.domain;

import com.alibaba.fastjson.JSONObject;
import com.github.d925529.apidoc.annotation.ApiField;
import org.beetl.sql.core.annotatoin.AssignID;
import org.beetl.sql.core.annotatoin.Param;
import org.beetl.sql.core.annotatoin.Table;
import org.beetl.sql.core.mapper.BaseMapper;

import javax.persistence.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 说明：订单表
 * 作者：292303959@qq.com
 * 日期：2018-10-17 10:5:39
 * 版本：1.0.0
 */
@Table(name = "t_order")
@SuppressWarnings("unused")
public class TOrder implements Serializable {
    @AssignID
    //订单ID
    @ApiField("订单ID")
    private String orderid;
    
    //会员ID
    @ApiField("会员ID")
    private String mid;
    
    //订单状态 0-待付款1-待发货(已付款)2-待收货3-已收货4-已完成 
    @ApiField("订单状态 0-待付款1-待发货(已付款)2-待收货3-已收货4-已完成 ")
    private String orderstatus;
    
    //订单金额
    @ApiField("订单金额")
    private java.math.BigDecimal orderamount;
    
    //下单时间
    @ApiField("下单时间")
    private String underdate;
    
    //付款时间
    @ApiField("付款时间")
    private String paydate;
    @ApiField("发货时间")
    private String senddate;
    //收货时间
    @ApiField("收货时间")
    private String revdate;
    
    //完成时间
    @ApiField("完成时间")
    private String finishdate;
    
    //收件人
    @ApiField("收件人")
    private String recipients;
    
    //手机
    @ApiField("手机")
    private String cellphone;
    
    //省
    @ApiField("省")
    private String province;
    
    //市
    @ApiField("市")
    private String city;
    
    //地区
    @ApiField("地区")
    private String area;
    
    //地址
    @ApiField("地址")
    private String adress;
    
    //邮政编码
    @ApiField("邮政编码")
    private String zipcode;

    //邮政编码
    @ApiField("支付流水号")
    private String paynumber;
    
    //支付方式(0-微信1-银联2-线下)
    @ApiField("支付方式(0-微信1-银联2-线下)")
    private String paytype;
    
    //是否首单(0-否1-是)
    @ApiField("是否首单(0-否1-是)")
    private String isfirst;
    
    @ApiField("留言")
    private String leaveword;
    @ApiField("上级id")
    private String pmid;
    @ApiField("折扣")
    private BigDecimal discount;
    @ApiField("原价")
    private BigDecimal originalprice;
    @ApiField("售后状态0-正常1-审核中")
    private String salestatus;

    @ApiField("购买总数")
    @Transient
    private Integer totalnum;

    public String getSalestatus() {
        return salestatus;
    }

    public void setSalestatus(String salestatus) {
        this.salestatus = salestatus;
    }

    public String getSenddate() {
        return senddate;
    }

    public void setSenddate(String senddate) {
        this.senddate = senddate;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

    public BigDecimal getOriginalprice() {
        return originalprice;
    }

    public void setOriginalprice(BigDecimal originalprice) {
        this.originalprice = originalprice;
    }

    public Integer getTotalnum() {
        return totalnum;
    }

    public void setTotalnum(Integer totalnum) {
        this.totalnum = totalnum;
    }

    public String getPmid() {
        return pmid;
    }

    public void setPmid(String pmid) {
        this.pmid = pmid;
    }

    public String getLeaveword() {
        return leaveword;
    }

    public void setLeaveword(String leaveword) {
        this.leaveword = leaveword;
    }

    /**
     * @return 订单ID
     */
    public String getOrderid(){
        return orderid;
    }
    /**
     * @param orderid 订单ID
     */
    public void setOrderid(String orderid){
        this.orderid = orderid;
    }
    
    /**
     * @return 会员ID
     */
    public String getMid(){
        return mid;
    }
    /**
     * @param mid 会员ID
     */
    public void setMid(String mid){
        this.mid = mid;
    }
    
    /**
     * @return 订单状态 0-待付款1-待发货(已付款)2-待收货3-已收货4-已完成 
     */
    public String getOrderstatus(){
        return orderstatus;
    }
    /**
     * @param orderstatus 订单状态 0-待付款1-待发货(已付款)2-待收货3-已收货4-已完成 
     */
    public void setOrderstatus(String orderstatus){
        this.orderstatus = orderstatus;
    }
    
    /**
     * @return 订单金额
     */
    public java.math.BigDecimal getOrderamount(){
        return orderamount;
    }
    /**
     * @param orderamount 订单金额
     */
    public void setOrderamount(java.math.BigDecimal orderamount){
        this.orderamount = orderamount;
    }
    
    /**
     * @return 下单时间
     */
    public String getUnderdate(){
        return underdate;
    }
    /**
     * @param underdate 下单时间
     */
    public void setUnderdate(String underdate){
        this.underdate = underdate;
    }
    
    /**
     * @return 付款时间
     */
    public String getPaydate(){
        return paydate;
    }
    /**
     * @param paydate 付款时间
     */
    public void setPaydate(String paydate){
        this.paydate = paydate;
    }
    
    /**
     * @return 收货时间
     */
    public String getRevdate(){
        return revdate;
    }
    /**
     * @param revdate 收货时间
     */
    public void setRevdate(String revdate){
        this.revdate = revdate;
    }
    
    /**
     * @return 完成时间
     */
    public String getFinishdate(){
        return finishdate;
    }
    /**
     * @param finishdate 完成时间
     */
    public void setFinishdate(String finishdate){
        this.finishdate = finishdate;
    }
    
    /**
     * @return 收件人
     */
    public String getRecipients(){
        return recipients;
    }
    /**
     * @param recipients 收件人
     */
    public void setRecipients(String recipients){
        this.recipients = recipients;
    }
    
    /**
     * @return 手机
     */
    public String getCellphone(){
        return cellphone;
    }
    /**
     * @param cellphone 手机
     */
    public void setCellphone(String cellphone){
        this.cellphone = cellphone;
    }
    
    /**
     * @return 省
     */
    public String getProvince(){
        return province;
    }
    /**
     * @param province 省
     */
    public void setProvince(String province){
        this.province = province;
    }
    
    /**
     * @return 市
     */
    public String getCity(){
        return city;
    }
    /**
     * @param city 市
     */
    public void setCity(String city){
        this.city = city;
    }
    
    /**
     * @return 地区
     */
    public String getArea(){
        return area;
    }
    /**
     * @param area 地区
     */
    public void setArea(String area){
        this.area = area;
    }
    
    /**
     * @return 地址
     */
    public String getAdress(){
        return adress;
    }
    /**
     * @param adress 地址
     */
    public void setAdress(String adress){
        this.adress = adress;
    }
    
    /**
     * @return 邮政编码
     */
    public String getZipcode(){
        return zipcode;
    }
    /**
     * @param zipcode 邮政编码
     */
    public void setZipcode(String zipcode){
        this.zipcode = zipcode;
    }

    public String getPaynumber() {
        return paynumber;
    }

    public void setPaynumber(String paynumber) {
        this.paynumber = paynumber;
    }

    /**
     * @return 支付方式(0-微信1-银联2-线下)
     */
    public String getPaytype(){
        return paytype;
    }
    /**
     * @param paytype 支付方式(0-微信1-银联2-线下)
     */
    public void setPaytype(String paytype){
        this.paytype = paytype;
    }
    
    /**
     * @return 是否首单(0-否1-是)
     */
    public String getIsfirst(){
        return isfirst;
    }
    /**
     * @param isfirst 是否首单(0-否1-是)
     */
    public void setIsfirst(String isfirst){
        this.isfirst = isfirst;
    }
    


    public interface Mapper extends BaseMapper<TOrder> {

        /**
         * 订单列表
         * 当pmid与mid仅能传一个
         * @param orderstatus
         * @param finishdate
         * @param pmid
         * @param mid
         * @param begin
         * @param pagesize
         * @return
         */
        List<JSONObject> orderList(@Param("orderstatus")String orderstatus,
                                   @Param("finishdate")String finishdate,
                                   @Param("pmid")String pmid,
                                   @Param("mid")String mid,
                                   @Param("begin")Integer begin,
                                   @Param("pagesize")Integer pagesize);

        /**
         * 订单查询
         * @param orderid
         * @return
         */
        Map<String,Object> queryOrder(@Param("orderid")String orderid);

        /**
         * 查询订单物流,包含订单的任意一张图片
         * @param orderid
         * @return
         */
        Map<String,Object> queryDetailImgByOrderid(@Param("orderid")String orderid);


        /**
         * 查询是否首单
         * @param mid
         * @return
         */
        Integer selectIsFirst(@Param("mid")String mid);
        /**
         * 查询上下级别差
         * @param mid
         * @return
         */
        Integer selectMebType(@Param("mid")String mid);

        /**
         * 更新订单状态和明细奖励金额计算
         * @param orderid
         * @param paytype
         * @param fscale
         * @param rscale
         * @return
         */
        Integer updateOrderPay(@Param("orderid")String orderid,@Param("paytype")String paytype,@Param("fscale")BigDecimal fscale,
                           @Param("rscale")BigDecimal rscale,@Param("isfirst")String isfirst);

        /**
         * 订单发货更新状态
         * @param orderid
         * @return
         */
        Integer updateSendOrder(@Param("orderid")String orderid);
        /**
         * 订单详情查询
         * @param orderid
         * @return
         */
        Map<String,Object> queryOrderInfo(@Param("orderid")String orderid);
    }
}